#!/bin/bash
#读取s
s=$(<"$1")
#echo "$s"
if [[ $s -gt 0 ]]; then
	#decrease the semaphore
  	let "s--"
  	echo "$s" >$1
else
  if [ -e "lock.dat" ]; then
    rm "lock.dat"
    sleep 1
  fi
  touch "lock.dat"
    while [ -e "lock.dat" ];do
	    sleep 1
    done
fi
